package com.zq.zqmanager.controller;

import com.alibaba.fastjson.JSONObject;
import com.zq.zqmanager.utils.HttpClientService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.client.RestTemplate;

import java.util.ArrayList;
import java.util.List;

/**
 * @program: zqmanager
 * @Date: 2020/3/13 9:38
 * @Author: zhengqiang
 * @Description:
 */
@Controller
@RequestMapping("/httpclient")
public class HttpClientController {

    @Autowired
    private RestTemplate restTemplate;

    @Autowired
    private HttpClientService httpClientService;

    private static final String URL = "http://10.150.27.105:8090/payService/facade/service/v1";
    private static final String GETURL = "http://localhost:8080/myspringboot/test";

    @RequestMapping("/get")
    @ResponseBody
    public String get(){
        String result = this.httpClientService.doGet(URL,null,"UTF-8");
        return result;
    }

    @RequestMapping("/post")
    @ResponseBody
    public JSONObject post(){
        String jsonStr = "{\"body\":{\"bankCode\":\"103\",\"idCardType\":\"0\",\"idCardNo\":\"110108199108060420\",\"name\":\"黑的\",\"mobile\":\"13810203661\",\"requestNo\":\"202002_SCFQ_1582116117511845641081\",\"bankcardNo\":\"6222023155555888888\"},\"companyId\":\"ZDHR\",\"requestTimestamp\":1582167584558,\"serviceName\":\"ACC_AUTHENTICATION\",\"subSystemSign\":\"SCFQ\",\"systemSign\":\"XHFQ\"}";
        String result = this.httpClientService.post(URL,jsonStr,null);
        return JSONObject.parseObject(result);
    }

}
